//
//  XFPictureCell.m
//  SinaBlog_OC
//
//  Created by macs on 15/11/17.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

#import "XFPictureCell.h"
#import "UIImageView+WebCache.h"

@interface XFPictureCell ()

@property(nonatomic, weak) UIImageView *iconView;

@end

@implementation XFPictureCell

- (void)setPictUrl:(NSURL *)pictUrl {
  _pictUrl = pictUrl;
  [self.iconView sd_setImageWithURL:pictUrl];
}

// 1.重写 init 方法

- (instancetype)initWithFrame:(CGRect)frame {

  if (self = [super initWithFrame:frame]) {
    [self setupUI];
    [self setupFrame];
  }
  return self;
}

// 2. setupUI添加子控件
- (void)setupUI {
  UIImageView *iconView = [[UIImageView alloc] init];
  iconView.contentMode = UIViewContentModeScaleAspectFill;
  iconView.clipsToBounds = YES;
  [self.contentView addSubview:iconView];
  self.iconView = iconView;
}

// 3. setupFrame添加子控件约束
- (void)setupFrame {
  [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.right.top.bottom.equalTo(self.contentView);
  }];
}

@end
